package com.example.tliasmanagement.mapper;

import com.example.tliasmanagement.dto.EmpListDto;
import com.example.tliasmanagement.entity.Emp;
import com.example.tliasmanagement.vo.EmpListVo;
import com.example.tliasmanagement.vo.EmpVo;
import com.example.tliasmanagement.vo.NameValueVo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface EmpMapper {

    public List<EmpListVo> selectAll();

    @Select("select count(*) from emp")
    int totalCount();

    List<EmpListVo> selectPage(@Param("start") int start, @Param("pageSize")Integer pageSize);

    Page<EmpListVo> page(EmpListDto dto);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("INSERT INTO emp (username, password, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time)" +
            " VALUES (#{username}, #{password}, #{name}, #{gender}, #{phone}, #{job}, #{salary}, #{image}, #{entryDate}, #{deptId}, #{createTime}, #{updateTime})")
    void insert(Emp emp);

    void deleteByIds(List<Integer> ids);

    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

    EmpVo selectByIdWithExprList(Integer id);


    void update(Emp emp);

    @Select("select * from emp where username = #{username}")
    Emp selectByUsername(String username);

    @Select("select * from emp where phone = #{phone}")
    Emp selectByPhone(String phone);
    /**
     *  统计员工职位信息
     * */
    List<NameValueVo> empJobData();
    List<NameValueVo> empGenderData();

    List<EmpVo> select();
}